
function Elastic() {}

Elastic._2PI = Math.PI * 2;
	
Elastic.easeIn = function(t, b, c, d, a, p) 
{

	var s;
	a = a || 0;
	p = p || 0;
	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
	else s = p/Elastic._2PI * Math.asin (c/a);
	return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*Elastic._2PI/p )) + b;
};

Elastic.easeOut  = function(t, b, c, d, a, p ) 
{
	var s;
	a = a || 0;
	p = p || 0;
	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
	else s = p/Elastic._2PI * Math.asin (c/a);
	return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*Elastic._2PI/p ) + c + b);
};

Elastic.easeInOut = function (t, b, c, d, a, p) 
{
	var s;
	a = a || 0;
	p = p || 0;
	if (t==0) return b;  if ((t/=d*0.5)==2) return b+c;  if (!p) p=d*(.3*1.5);
	if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
	else s = p/Elastic._2PI * Math.asin (c/a);
	if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*Elastic._2PI/p )) + b;
	return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*Elastic._2PI/p )*.5 + c + b;
};